package Solutions;

public class Solution9 {
    public static void main(String[] args) {
        String password = "s3cur1tyC0d3";
        int target = 4;
        new solution09().dynamicPassword(password,target);
    }
}
class solution09 {
    public String dynamicPassword(String password, int target) {
        StringBuilder sb=new StringBuilder();
        StringBuilder sb2=new StringBuilder();
        //遍历字符串，找出前target个字符组成一个新字符串
        for (int i=0;i<password.length();i++){
            //左侧目标拼成的新字符
            if (i<=target-1) {
               sb.append(password.charAt(i));
            }else {
                //右侧剩下的
                sb2.append(password.charAt(i));
            }
        }
        //打印查看结果
        System.out.println(sb2.toString()+sb.toString());
        //将左侧放到末尾
        return sb2.toString()+sb.toString();
    }
}
